package cn.bigfire.compiler.dragon.appendixA.handwrite.inter;

import cn.bigfire.compiler.dragon.appendixA.handwrite.symbols.Type;

public class If extends Stmt {

    Expr expr;
    Stmt stmt;

    public If(Expr expr, Stmt stmt) {
        this.expr = expr;
        this.stmt = stmt;
        if (expr.type != Type.Bool) {
            expr.error("boolean required in if");
        }
    }

    public void gen(int b, int a) {
        int label = newLabel();
        expr.jumping(0, a);
        emitLabel(label);
        stmt.gen(label, a);
    }

}
